package com.ktg.service.impl;

import com.ktg.ktgcommon.domain.TmTool;
import com.ktg.ktgcommon.utils.Page;
import com.ktg.mapper.TmToolMapper;
import com.ktg.service.TmToolService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TmToolServiceImpl implements TmToolService {
    @Resource
    public TmToolMapper tmToolMapper;
    @Override
    public Page<TmTool> findPage(TmTool entity, Integer pageNo, Integer pageSize) {
        Page<TmTool> page = new Page<>();
        page.setPageSize(pageSize);
        //查询总数，计算总页数
        Long count = tmToolMapper.count();
        page.setTotalCount(count.intValue());
        page.setPageNo(pageNo);
        //查询分页数据
        List<TmTool> data = tmToolMapper.findPage(entity, page.offset(), page.getPageSize());
        page.setData(data);
        return page;
    }

    @Override
    public List<TmTool> toolTypeNameList() {
        return tmToolMapper.toolTypeNameList();
    }

    @Override
    public boolean update(TmTool entity) {
        return tmToolMapper.update(entity);
    }

    @Override
    public boolean add(TmTool entity) {
        return tmToolMapper.add(entity);
    }

    @Override
    public TmTool findById(Long toolId) {
        return tmToolMapper.findById(toolId);
    }
}
